J?Set Field [ result, External("TrFile-AppendContents", "text" )]
KeAppend characters to the contents of an existing file indicated by the
SetDefaultFileSpec
function.
MItext: the characters that you want to add at the end of the default file.
Assume your C disk already contains a file "Testtext.txt", which contains the text "Hello". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", "C:\Testtext.txt" )]
If [gErrorCode = 0]
Set Field[gErrorCode, External("TrFile-AppendContents", " there." )]
Endif
This script will add the text " there." to the end of the file. After running the script once the file will conta
To be able to specify a file, the plug-in uses FileSpec, which is short for File Specification.
On Windows this is always a full path like:
"C:\Data Files\Database\Test.Txt".
On Mac OS the file spec can be a full path like this:
"Mac HD:Data Files:Database:testfile"
or it can be a FSSpec:
":volumeID:directoryID:fileName"
The plug-in recognizes the FSSpec by the colon as the first character.
An example may be: ":-1:300:testfile".
On the Mac a volume name need not beB unique, be careful with that.
On the Mac a disk name need not be unique, be careful with that.
To be able to specify a file, the plug-in uses FileSpec, which is short for File Specification.
On Windows this is always a full path like:
"C:\Data Files\Database\Test.Txt".
On Mac OS the file spec can be a full path like this:
"Mac HD:Data Files:Database:testfile"
or it can be a FSSpec:
":volumeID:directoryID:fileName"
The plug-in recognizes the FSSpec by the colon as the first character.
An example may be: ":-1:300:testfile".
On the Mac a volume name need not beBw unique, be careful with that.
On the Mac a disk name need not be unique, be careful with that.
4/3/2000
3:51:57 PM
TrFile-ContentsDialogf
FileSpecj
Filesu
Troi File Plug-in
D0001
JQSet Field [ result, External("TrFile-ContentsDialog", "prompt | initialFolder" )]
Shows the user a file selection dialog, the contents of the selected file is returned.
This function is a combination of "TrFile-Get FileSpec Dialog" followed by a "TrFile-GetContents" function.
prompt: adds a prompt text to the GetFile Dialog. It may be left empty.
initialFolder: (optional) the FileSpec or path to the folder where the dialog initially starts.
in "Hello there.". If you run the script again the file will contain "Hello there. there."
EXAMPLE 2
This shows how to write to a log file. We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number gXplatformReturn Global, text
gLogFilePath Global, text gLogtext Global, text
gLogFilePath should contain the path to an existing log file, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). gXplatformReturn s
hould contain a return on Mac and a return and a linefeed on Windows. gLogtext is the text you want to log. In ScriptMaker add the following scriptstep to your startup script:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gLogFilePath )]
This will set the default file to your log file. Then whenever you need to write a line to the log fill the field gLogtext and perform this script step:
Set Field[gErrorCode, External("TrFile-AppendContents",
oThe returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The string of characters were added to the file
$$-1 genericErr The file could not be opened for appending (You might need to create the file first).
Other errors may be returned.
Use the function "TrFile-SetDefaultFileSpec" first to set the default file. See also the functions:
"TrFile-Save FileSpec Dialog" to ask the user for a FileSpec, "TrFile-SetDefaultFileSpec" to indicate the file to affect.
Append characters to the contents of an existing file indicated by the
SetDefaultFileSpec
function.
** text: the characters that you want to add at the end of the default file.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The string of characters were added to the file
$$-1 genericErr The file could not be opened for appending (You might need t
o create the file first).
Other errors may be returned.
** Use the function "TrFile-SetDefaultFileSpec" first to set the default file. See also the functions:
"TrFile-Save FileSpec Dialog" to ask the user for a FileSpec, "TrFile-SetDefaultFileSpec" to indicate the file to affect.
** Assume your C disk already contains a file "Testtext.txt", which contains the text "Hello". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-AppendContents", " there." )]
Endif
This script will add the text " there." to the end of the file. After running the script once the file will contain "Hello there.". If you run the script again the file will contain "Hello there. there."
EXAMPLE 2
This shows how to write to a log file. We assume that in your FileMaker file the following fields are de
fined:
gErrorCode Global, number gXplatformReturn Global, text
gLogFilePath Global, text gLogtext Global, text
gLogFilePath should contain the path to an existing log file, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). gXplatformReturn should contain a return on Mac and a return and a linefeed on Windows. gLogtext is the text you want to log. In ScriptMaker add the following scriptstep to your startup script:
Set Field[gErrorCode, Externa
l("TrFile-SetDefaultFileSpec", gLogFilePath )]
This will set the default file to your log file. Then whenever you need to write a line to the log fill the field gLogtext and perform this script step:
Set Field[gErrorCode, External("TrFile-AppendContents",
source FileSpec: the Filespec or path to the file to copy.
destination FileSpec: the Filespec or path where the file must be copied to.
Assume your C disk already contains a file "Testtext.txt". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-CopyFile", "C:\Testtext.txt|D:\MyFiles\TestDupl.txt" )]
This script will copy the file "Testtext.txt" to the "TestDupl.txt" file in directory "MyFiles" on the D: disk. On Mac OS the paths will be of the form "Mac HD:MyFiles:TestDupl.txt".
EXAMPLE 2
We assume that in your FileMaker
Set Field [ result, External["TrFile-ContentsDialog", "Please select the text file you want to be used:|D:\DataFiles\" )]
You can also use a calculation for the prompt, for example this one which uses a global text field:
Set Field [ result, External["TrFile-ContentsDialog", "Please select the Excel file """ & gFileName & """:" )]
This will result in a file selection dialog with this prompt text: 'Please select the Excel file "invoices99.xls":'.
OjThe characters of the file the user selected. If the user pressed cancel an error code "$$-1" is returned.
[FileMaker fields are limited to 64000 characters. So files longer than 64000 bytes are cut after the 64000th character. Use the partial reading of "TrFile-GetContents" to read in longer files.
Aslo note that high ASCII characters are not converted to the internal Filemaker format. Use "TrFile-ConvertToFMText" to convert to the Filemaker format.
Shows the user a file selection dialog, the contents of the selected file is returned.
This function is a combination of "TrFile-Get FileSpec Dialog" followed by a "TrFile-GetContents" function.
** prompt: adds a prompt text to the GetFile Dialog. It may be left empty.
initialFolder: (optional) the FileSpec or path to the folder where the dialog initially starts.
** The characters of the file the user selected. If the user pressed cancel an error code "$$-1" is returned.
** FileMaker fi
elds are limited to 64000 characters. So files longer than 64000 bytes are cut after the 64000th character. Use the partial reading of "TrFile-GetContents" to read in longer files.
Aslo note that high ASCII characters are not converted to the internal Filemaker format. Use "TrFile-ConvertToFMText" to convert to the Filemaker format.
** Set Field [ result, External["TrFile-ContentsDialog", "Please select the text file you want to be used:|D:\DataFiles\" )]
You can also use a calculati
5on for the prompt, for example this one which uses a global text field:
Set Field [ result, External["TrFile-ContentsDialog", "Please select the Excel file """ & gFileName & """:" )]
This will result in a file selection dialog with this prompt text: 'Please select the Excel file "invoices99.xls":'.
4/3/2000
4:13:56 PM
TrFile-CreateFilef
FileSpecj
Filesu
Troi File Plug-in
D0001
J?Set Field [ result, External("TrFile-CreateFile", "FileSpec" )]
KqCreates a new empty file in the location indicated by the FileSpec. This function requires no user intervention.
M6FileSpec: the Filespec or path to the file to create.
Set Field[gErrorCode, External("TrFile-CreateFile", "C:\Testtext.txt" )]
This will create the empty file "Testtext.txt" on the C disk.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gDestFilePath Global, text
gDestFilePath should contain the path to the destination and should not exist, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following scriptstep:
This will create the file indicated in the gDestFilePath.
file the following fields are defined:
gErrorCode Global, number
gSourceFilePath Global, text
gDestFilePath Global, text
gSourceFilePath should contain the path to an existing file, for example "D:\Logs\Log01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). gDestFilePath should contain the path to the destination and should not exist, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gErrorCodC
e, External("TrFile-CopyFile", gSourceFilePath & "|" & gDestFilePath )]
This will copy the source file to the path indicated in the gDestFilePath.
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was copied
$$-43 fnfErr Source file not found, or destination directory does not exist
$$-48 dupFNErr Destination file already exists
$$-1 genericErr The file could not be copied
Other errors may be returned.
Use the TrFile-DeleteFile to delete a file first if it exists. See also the function "TrFile-Save FileSpec Dialog" to get a FileSpec for a file.
Copies a file to the specified path.
** source FileSpec: the Filespec or path to the file to copy.
destination FileSpec: the Filespec or path where the file must be copied to.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was copied
$$-43 fnfErr Source file not found, or destination directory does not exist
$$-48 dupFNErr Destinat
ion file already exists
$$-1 genericErr The file could not be copied
Other errors may be returned.
** Use the TrFile-DeleteFile to delete a file first if it exists. See also the function "TrFile-Save FileSpec Dialog" to get a FileSpec for a file.
** Assume your C disk already contains a file "Testtext.txt". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-CopyFile", "C:\Testtext.txt|D:\
MyFiles\TestDupl.txt" )]
This script will copy the file "Testtext.txt" to the "TestDupl.txt" file in directory "MyFiles" on the D: disk. On Mac OS the paths will be of the form "Mac HD:MyFiles:TestDupl.txt".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gSourceFilePath Global, text
gDestFilePath Global, text
gSourceFilePath should contain the path to an existing file, for example "D:\Logs\Log01.TXT" (Windows) or "
Mac HD:Logs:Log 1" (Mac). gDestFilePath should contain the path to the destination and should not exist, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-CopyFile", gSourceFilePath & "|" & gDestFilePath )]
This will copy the source file to the path indicated in the gDestFilePath.
4/3/2000
4:13:56 PM
TrFile-CreateFolderf
FileSpecj
Filesu
Troi File Plug-in
D0001
JASet Field [ result, External("TrFile-CreateFolder", "FileSpec" )]
K-Creates a new (empty) folder (subdirectory).
M,FileSpec : the path to the folder to create.
We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-CreateFolder", "C:\Data\NewFolder\" )]
This script will create the folder "NewFolder" inside the Data folder on the C disk.
On Mac OS this will be:
Set Field[gErrorCode, External("TrFile-CreateFolder", "MyDisk:Data:NewFolder:" )]
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, nu
OThe returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was created
$$-48 dupFNErr Destination file already exists
$$-1 genericErr The file could not created
Other errors may be returned.
RSSee also the function "TrFile-Save FileSpec Dialog" to get a FileSpec for the file.
Creates a new empty file in the location indicated by the FileSpec. This function requires no user intervention.
** FileSpec: the Filespec or path to the file to create.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was created
$$-48 dupFNErr Destination file already exists
$$-1 genericErr The file could not created
Other errors
may be returned.
** See also the function "TrFile-Save FileSpec Dialog" to get a FileSpec for the file.
** Set Field[gErrorCode, External("TrFile-CreateFile", "C:\Testtext.txt" )]
This will create the empty file "Testtext.txt" on the C disk.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gDestFilePath Global, text
gDestFilePath should contain the path to the destination and should not exist, for example "D:\Logs\L2000_C
01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-CreateFile", gDestFilePath )]
This will create the file indicated in the gDestFilePath.
4/3/2000
4:13:56 PM
TrFile-DeleteFilef
FileSpecj
Filesu
Troi File Plug-in
D0001
J?Set Field [ result, External("TrFile-DeleteFile", "FileSpec" )]
KXDeletes the file indicated by the FileSpec. This function requires no user intervention.
M6FileSpec: the Filespec or path to the file to delete.
Assume your C disk already contains a file "TestFile.xls". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-DeleteFile", "C:\TestFile.xls" )]
This script will delete the file "TestFile.xls". On Mac OS the path will be of the form "Mac HD:TestFile.xls".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
rmber
gFolderPath Global, text
gFolderPath should contain the path to the folder to be created and should not exist, for example "D:\Logs\Data\" (Windows) or "Mac HD:Logs:Data:" (Mac OS). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-CreateFolder", gFolderPath )]
This will create the folder specified in the gFolderPath.
XThe returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The folder was created
$$-48 dupFNErr Destination folder already exists
$$-1 genericErr The folder could not be created
Other errors may be returned.
See also the functions: "TrFile-Save FileSpec Dialog" to get a FileSpec for a folder,
"TrFile-CreateFile" to create a new empty file.
Creates a new (empty) folder (subdirectory).
** FileSpec : the path to the folder to create.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The folder was created
$$-48 dupFNErr Destination folder already exists
$$-1 genericErr The folder could not be created
Other errors may be returned.
** See also the functions: "TrFile-Save FileSpec Dia
log" to get a FileSpec for a folder,
"TrFile-CreateFile" to create a new empty file.
** We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-CreateFolder", "C:\Data\NewFolder\" )]
This script will create the folder "NewFolder" inside the Data folder on the C disk.
On Mac OS this will be:
Set Field[gErrorCode, External("TrFile-CreateFolder", "MyDisk:Data:NewFolder:" )]
EXAMPLE 2
We assu
me that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFolderPath Global, text
gFolderPath should contain the path to the folder to be created and should not exist, for example "D:\Logs\Data\" (Windows) or "Mac HD:Logs:Data:" (Mac OS). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-CreateFolder", gFolderPath )]
This will create the folder specified in the gFolderPath.
4/3/2000
4:13:56 PM
TrFile-FileSpec To FullPathf
FileSpecj
Filesu
Troi File Plug-in
D0001
JISet Field [ result, External("TrFile-FileSpec To FullPath", "FileSpec" )]
KCReturns full path of a file or folder from the FSSpec. Mac OS only.
M^FileSpec: the FSSpec of a file or folder. It is of the form ":volumeID:directoryID:fileName"
Set Field[result, External("TrFile-FileSpec To FullPath", ":-1:300:testfile" )]
If the FSSpec is valid this may return something like this:
"Mac HD:Data Files:Database:testfile"
EXAMPLE 2
We assume that in your FileMaker file the following field is defined:
gFilePath Global, text
gFilePath should contain the path to an existing file, for example ":-1:300:testfile". In ScriptMaker add the following scriptstep:
Set Field[gFilePath, External("TrFile-FileSpec To FullPath", gFiBDlePath )]
This will convert the FSSpec in gFilePath to a Full Path.
4gFilePath should contain the path to an existing file which you want to delete, for example "D:\Logs\Log01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-DeleteFile", gFilePath )]
This will delete the file from the disk.
HThe returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was deleted
$$-43 fnfErr The file was not found
$$-1 genericErr The file could not be deleted
Other errors may be returned.
WARNING: The file is not moved to the Trash, but deleted completely. This can not be undone!
See also
TrDl-DoDialog
or use the
Show Message
script step if you want to warn the user.
Deletes the file indicated by the FileSpec. This function requires no user intervention.
** FileSpec: the Filespec or path to the file to delete.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was deleted
$$-43 fnfErr The file was not found
$$-1 genericErr The file could not be deleted
Other errors may be returned.
** WARNING: The
file is not moved to the Trash, but deleted completely. This can not be undone!
See also
TrDl-DoDialog
or use the
Show Message
script step if you want to warn the user.
** Assume your C disk already contains a file "TestFile.xls". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-DeleteFile", "C:\TestFile.xls" )]
This script will delete the file "TestFile.xls". On Mac OS the path will be
of the form "Mac HD:TestFile.xls".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
gFilePath should contain the path to an existing file which you want to delete, for example "D:\Logs\Log01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-DeleteFile", gFilePath )]
On the Mac a disk name need not be unique, be careful with that.
See also the function
TrFile-FullPath To FileSpec
to revert the path name.
** Set Field[result, External("TrFile-FileSpec To FullPath", ":-1:300:
testfile" )]
If the FSSpec is valid this may return something like this:
"Mac HD:Data Files:Database:testfile"
EXAMPLE 2
We assume that in your FileMaker file the following field is defined:
gFilePath Global, text
gFilePath should contain the path to an existing file, for example ":-1:300:testfile". In ScriptMaker add the following scriptstep:
Set Field[gFilePath, External("TrFile-FileSpec To FullPath", gFilePath )]
This will convert the FSSpec in gFilePath to a Full PathC
4/3/2000
4:13:56 PM
TrFile-FindFolderf
folderconstantj
Filesu
Troi File Plug-in
D0001
JESet Field [ result, External("TrFile-FindFolder", "folderconstant" )]
K>Finds special folders (subdirectories). Currently Mac OS only.
folderconstant: Specifies which folder to return, must be one of the following:
desktop = desktop folder
system = system folder
trash = trash folder on the desktop
shutdown = shutdown items folder in the system folder
applemenu = apple menu folder in the system folder
controlpanels = control panels folder in the system folder
extensions = extensions folder in the system folder
preferences = preferences folder in the system folder
temporary = hidden temporary folder on the stB2artup disk
root = top folder on the startup disk
LSet Field [ result, External["TrFile-FindFolder", "trash" )]
This will return the FSSpec of the Trash folder.
TIP: With this folder and the MoveFile function you can move items into the Trash.
EXAMPLE 2
Set Field [ gStartupDiskFolder, External["TrFile-FindFolder", "root" )]
This will return the top folder on the startup disk.
O&FileSpec: The Filespec of the folder.
R/Currently Mac OS only. Returns $$-1 on Windows.
Finds special folders (subdirectories). Currently Mac OS only.
** folderconstant: Specifies which folder to return, must be one of the following:
desktop = desktop folder
system = system folder
trash = trash folder on the desktop
shutdown = shutdown items folder in the system folder
applemenu = apple menu folder in the system folder
controlpanels = control panels folder in the system folder
extensions = extensions folder in the system folder
preferences = preferences folder
in the system folder
temporary = hidden temporary folder on the startup disk
root = top folder on the startup disk
** FileSpec: The Filespec of the folder.
** Currently Mac OS only. Returns $$-1 on Windows.
** Set Field [ result, External["TrFile-FindFolder", "trash" )]
This will return the FSSpec of the Trash folder.
TIP: With this folder and the MoveFile function you can move items into the Trash.
EXAMPLE 2
Set Field [ gStartupDiskFolder, External["TrFile-FindFolder", "root" )]
TC7his will return the top folder on the startup disk.
4/3/2000
4:13:56 PM
TrFile-FolderListf
switches | FileSpecj
Filesu
Troi File Plug-in
D0001
JJSet Field [ result, External("TrFile-FolderList", "switches | FileSpec" )]
KuLists what is inside a folder (directory). It will return all files and/or folders, depending on the switches given.
switches: these determine the items that are listed.
FileSpec: the FileSpec or path to the folder to list.
switches can be one or more of the following:
files list all files in this folder
folders list all folders (subdirectories) in this folder
showaliases list all aliases (shortcuts) in this folder
showshortcuts list all aliases (shortcuts) in this folder (you can use the one you like)
showinvisibles list all invisible files and folders
showpointdirs Windows: list also the directoryBR . (current dir) and .. (parent dir)
showpointdirs Mac OS: this switch is ignored
Set Field [ result, External("TrFile-ListFolder"; "files & folders |Mac HD:") ]
This will return a list of all files and folders on the hard disk "Mac HD". Note that the order of the switches is not relevant, and also the & is just there for readability. This might be returned:
Test.fp3
Desktop Folder
Program files
etc...
On Windows an example usage is:
Set Field [ result, External("TrFile-ListFolder"; "files & showshortcuts|C:\Data\") ]
This will return a list of all files
and shortcuts on the hard disk "C:\Data\".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFolderPath Global, text
gFolderList Global, text
gFolderPath should contain the path to the folder, for example "D:\Logs\Data\" (Windows) or "Mac HD:Logs:Data:" (Mac OS). In ScriptMaker add the following scriptstep:
Set Field[gFolderList, External("TrFile-FolderList", "files & folders |" & gFolderPath )]
This will list the contents of the folder sp
ecified in the gFolderPath.
O@folder list a list of names of the items separated by returns.
RANote that each item, including the last, is followed by a return.
Lists what is inside a folder (directory). It will return all files and/or folders, depending on the switches given.
** switches: these determine the items that are listed.
FileSpec: the FileSpec or path to the folder to list.
switches can be one or more of the following:
files list all files in this folder
folders list all folders (subdirectories) in this folder
showaliases list all aliases (shortcuts) in this folder
showshortcuts list all aliases (shortcuts) in this folder (you can
use the one you like)
showinvisibles list all invisible files and folders
showpointdirs Windows: list also the directory . (current dir) and .. (parent dir)
showpointdirs Mac OS: this switch is ignored
** folder list a list of names of the items separated by returns.
** Note that each item, including the last, is followed by a return.
** Set Field [ result, External("TrFile-ListFolder"; "files & folders |Mac HD:") ]
This will return a list of all files and folders on the hard disk "M
ac HD". Note that the order of the switches is not relevant, and also the & is just there for readability. This might be returned:
Test.fp3
Desktop Folder
Program files
etc...
On Windows an example usage is:
Set Field [ result, External("TrFile-ListFolder"; "files & showshortcuts|C:\Data\") ]
This will return a list of all files and shortcuts on the hard disk "C:\Data\".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFolderPath Global,
w text
gFolderList Global, text
gFolderPath should contain the path to the folder, for example "D:\Logs\Data\" (Windows) or "Mac HD:Logs:Data:" (Mac OS). In ScriptMaker add the following scriptstep:
Set Field[gFolderList, External("TrFile-FolderList", "files & folders |" & gFolderPath )]
This will list the contents of the folder specified in the gFolderPath.
4/3/2000
4:13:56 PM
TrFile-FullPath To FileSpecf
FileSpecj
Filesu
Troi File Plug-in
D0001
JISet Field [ result, External("TrFile-FullPath To FileSpec", "FileSpec" )]
K=Changes the full name path to the standard Macintosh FSSpec.
M~FileSpec: the Full path of a file or folder. It is of the form
KOPresents the user with a standard dialog and displays all files in a directory.
prompt: the prompt that will be displayed to tell the user which file to select.
initialFolder: (optional) the FileSpec or path to the folder where the dialog initially starts.
On MacOS:
Set Field[MyFileName, External("TrFile-Get FileSpec Dialog", "Please choose a file to import|Mac HD:Solution Files:Import:")]
Or on Windows:
Set Field[MyFileName, External("TrFile-Get FileSpec Dialog", "Please choose a file to import|C:\Solution Files\Import\")]
This will start the selection at the folder "Import" in the "Solution Files" Folder. It returns "HD Mac:Text files:My Letter" if the user selects that particular file on MacOS. On Windows it may return "C:\Text filesB
\My Letter".
FileSpec: The function returns a FileSpec for the selected file to be used with one of the file
manipulation functions.
If the user cancels an error code of "$$-1" is returned.
Presents the user with a standard dialog and displays all files in a directory.
** prompt: the prompt that will be displayed to tell the user which file to select.
initialFolder: (optional) the FileSpec or path to the folder where the dialog initially starts.
** FileSpec: The function returns a FileSpec for the selected file to be used with one of the file
manipulation functions.
If the user cancels an error code of "$$-1" is returned.
** On MacOS:
Set Field[MyFileName, Externa
l("TrFile-Get FileSpec Dialog", "Please choose a file to import|Mac HD:Solution Files:Import:")]
Or on Windows:
Set Field[MyFileName, External("TrFile-Get FileSpec Dialog", "Please choose a file to import|C:\Solution Files\Import\")]
This will start the selection at the folder "Import" in the "Solution Files" Folder. It returns "HD Mac:Text files:My Letter" if the user selects that particular file on MacOS. On Windows it may return "C:\Text files\My Letter".
4/3/2000
4:13:56 PM
TrFile-GetContentsf
promptj
Filesu
Troi File Plug-in
D0001
JOSet Field [ result, External("TrFile-GetContents", "fileSpec| start | size" )]
Returns (a part of) the contents of the file specified by the FileSpec. When a start is given this function extracts characters from the specified file, starting at the position specified by start and containing the number of characters specified by size.
fileSpec: the Filespec or path to the file.
start: (optional) starting position in the file.
size: (optional) the number of characters to get.
Set Field[MyTextField, External("TrFile-GetContents", "HD Mac:Text files:My Letter")]
returns the contents of the file.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gContents Global, text gStart Global, number
gFileSpec Global, text gLength Global, number
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In gStart should be the start pos
ition and in gLength the number of bytes you want to get. In ScriptMaker add the following scriptstep:
This will get part of the contents of the file into the gContents field.
OcThe characters of the file specified. If the user pressed cancel an error code "$$-1" is returned.
JFileMaker fields are limited to 64000 characters. So results longer than 64000 bytes are cut after the 64000th character. Use start and size parameter to read in longer files.
Also note that High ASCII characters are not converted to the internal Filemaker format. Use "TrFile-ConvertToFMText" to convert to the Filemaker format.
Returns (a part of) the contents of the file specified by the FileSpec. When a start is given this function extracts characters from the specified file, starting at the position specified by start and containing the number of characters specified by size.
** fileSpec: the Filespec or path to the file.
start: (optional) starting position in the file.
size: (optional) the number of characters to get.
** The characters of the file specified. If the user pressed cancel an error code "$$-1
" is returned.
** FileMaker fields are limited to 64000 characters. So results longer than 64000 bytes are cut after the 64000th character. Use start and size parameter to read in longer files.
Also note that High ASCII characters are not converted to the internal Filemaker format. Use "TrFile-ConvertToFMText" to convert to the Filemaker format.
** Set Field[MyTextField, External("TrFile-GetContents", "HD Mac:Text files:My Letter")]
returns the contents of the file.
EXAMPLE 2
We assum
e that in your FileMaker file the following fields are defined:
gContents Global, text gStart Global, number
gFileSpec Global, text gLength Global, number
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In gStart should be the start position and in gLength the number of bytes you want to get. In ScriptMaker add the following scriptstep:
This will get part of the contents of the file into the gContents field.
4/3/2000
4:13:56 PM
TrFile-GetDataSizef
FileSpecj
Filesu
Troi File Plug-in
D0001
J@Set Field [ result, External("TrFile-GetDataSize", "FileSpec" )]
Returns the size of the data for the file specified by the FileSpec. The size indicates the actual number of bytes used by the data fork.
M,FileSpec: the Filespec or path to the file.
Assume there is a file "Read me" with the text "Hello!" in it. Then:
Set Field[MyTextField, External("TrFile-GetDataSize", "Disk:Read me")]
returns 6, which is the size of the data in the file. The total file size may be bigger.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text
gSize Global, number
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.B
txt" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gSize, External("TrFile-GetDataSize", gFileSpec)]
This will fill gSize with the size of the data.
The size (in bytes) of the data of the file specified. On Mac a file can have a data fork and also a resource fork. On Mac OS this function returns the size of the data fork only.
RHSee also the functions "TrFile-GetFileSize" and "TrFile-GetResForkSize".
Returns the size of the data for the file specified by the FileSpec. The size indicates the actual number of bytes used by the data fork.
** FileSpec: the Filespec or path to the file.
** The size (in bytes) of the data of the file specified. On Mac a file can have a data fork and also a resource fork. On Mac OS this function returns the size of the data fork only.
** See also the functions "TrFile-GetFileSize" and "TrFile-GetResForkSize".
** Assume there is a file "Read me" with the t
ext "Hello!" in it. Then:
Set Field[MyTextField, External("TrFile-GetDataSize", "Disk:Read me")]
returns 6, which is the size of the data in the file. The total file size may be bigger.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text
gSize Global, number
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In ScriptMaker add the followin
g scriptstep:
Set Field[gSize, External("TrFile-GetDataSize", gFileSpec)]
This will fill gSize with the size of the data.
4/3/2000
4:13:56 PM
TrFile-GetDateCreatedf
FileSpecj
Filesu
Troi File Plug-in
D0001
JCSet Field [ result, External("TrFile-GetDateCreated", "FileSpec" )]
KAReturns the creation date for the file specified by the FileSpec.
MNFileSpec: the Filespec or path to the file for which you want the information.
Set Field[creationDate, External("TrFile-GetDateCreated", "C:\Test.txt" )]
This may return the number 730172 which is equivalent to the date: 22 Feb. 2000.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
creationDate date
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following script step:
Set Field[creationDate, E
xternal("TrFile-GetDateCreated", gFilePath )]
This will store the creation date of the file specified by gFilePath in the field creationDate.
The returned result is the creation date of the file. The date is in the same format as a date field.
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
DESCRIPTION
Returns the creation date for the file specified by the FileSpec.
** FileSpec: the Filespec or path to the file for which you want the information.
** The returned result is the creation date of the file. The date is in the same format as a date field.
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be f
ound (older versions of the plug-in)
Other errors may be returned.
** Set Field[creationDate, External("TrFile-GetDateCreated", "C:\Test.txt" )]
This may return the number 730172 which is equivalent to the date: 22 Feb. 2000.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
creationDate date
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). I
n ScriptMaker add the following script step:
Set Field[creationDate, External("TrFile-GetDateCreated", gFilePath )]
This will store the creation date of the file specified by gFilePath in the field creationDate.
4/3/2000
4:13:56 PM
TrFile-GetDateModifiedf
FileSpecj
Filesu
Troi File Plug-in
D0001
JDSet Field [ result, External("TrFile-GetDateModified", "FileSpec" )]
Returns the modification date for the file specified by the FileSpec. The modification date is also displayed in the Finder or Explorer.
MNFileSpec: the Filespec or path to the file for which you want the information.
Set Field[modificationDate, External("TrFile-GetDateModified", "C:\Test.txt" )]
This may return the number 730173 which is equivalent to the date: 23 Feb. 2000.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
modificationDate date
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following script step:
This will store the modification date of the file specified by gFilePath in the field modificationDate.
The returned result is the modification date of the file. The date is in the same format as a date field.
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
Returns the modification date for the file specified by the FileSpec. The modification date is also displayed in the Finder or Explorer.
** FileSpec: the Filespec or path to the file for which you want the information.
** The returned result is the modification date of the file. The date is in the same format as a date field.
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not fo
und, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
** Set Field[modificationDate, External("TrFile-GetDateModified", "C:\Test.txt" )]
This may return the number 730173 which is equivalent to the date: 23 Feb. 2000.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
modificationDate date
gFilePath Global, text
gFilePath should contain the path to the file
>, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following script step:
Set Field[modificationDate, External("TrFile-GetDateModified", gFilePath )]
This will store the modification date of the file specified by gFilePath in the field modificationDate.
4/3/2000
4:13:56 PM
TrFile-GetDateTimeCreatedf
FileSpecj
Filesu
Troi File Plug-in
D0001
JGSet Field [ result, External("TrFile-GetDateTimeCreated", "FileSpec" )]
KKReturns the creation date and time for the file specified by the FileSpec.
MNFileSpec: the Filespec or path to the file for which you want the information.
Set Field[result, External("TrFile-GetDateTimeModified", "C:\Test.txt" )]
This may return the result: "2000-02-22 15:55:17".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
creationDateTime text
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L01.TXT" (Windows) or
"Mac HD:Logs:Log File 1" (Mac). In ScriptMaker add the following script step:
Set Field[creationDateTime, External("TrFile-GetDateTimeCB
reated", gFilePath )]
This will store the creation date and time of the file specified by gFilePath in the field creationDateTime.
The returned result is the creation date and time of the file. The result is formatted like this:
YYYY-MM-DD HH:MM:SS. Store the result in a text field.
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
Returns the creation date and time for the file specified by the FileSpec.
** FileSpec: the Filespec or path to the file for which you want the information.
** The returned result is the creation date and time of the file. The result is formatted like this:
YYYY-MM-DD HH:MM:SS. Store the result in a text field.
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if th
e path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
** Set Field[result, External("TrFile-GetDateTimeModified", "C:\Test.txt" )]
This may return the result: "2000-02-22 15:55:17".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
creationDateTime text
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L01.TXT" (Windows) or
"Mac
HD:Logs:Log File 1" (Mac). In ScriptMaker add the following script step:
Set Field[creationDateTime, External("TrFile-GetDateTimeCreated", gFilePath )]
This will store the creation date and time of the file specified by gFilePath in the field creationDateTime.
4/3/2000
4:13:56 PM
TrFile-GetDateTimeModifiedf
FileSpecj
Filesu
Troi File Plug-in
D0001
JHSet Field [ result, External("TrFile-GetDateTimeModified", "FileSpec" )]
Returns the modification date and time for the file specified by the FileSpec. The modification date and time are also displayed in the Finder or Explorer.
MNFileSpec: the Filespec or path to the file for which you want the information.
Set Field[result, External("TrFile-GetDateTimeModified", "C:\Test.txt" )]
This may return the result: "2000-12-31 15:55:17".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
modificationDateTime text
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following script step:
Set Field[modificationDateTime, External("TrFileB
-GetDateTimeModified", gFilePath )]
This will store the modification date and time of the file specified by gFilePath in the field modificationDateTime.
The returned result is the modification date and time of the file. The result is formatted like this:
YYYY-MM-DD HH:MM:SS. Store the result in a text field.
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
Returns the modification date and time for the file specified by the FileSpec. The modification date and time are also displayed in the Finder or Explorer.
** FileSpec: the Filespec or path to the file for which you want the information.
** The returned result is the modification date and time of the file. The result is formatted like this:
YYYY-MM-DD HH:MM:SS. Store the result in a text field.
An error code might also be returned. An error always starts with 2 dollars, followed by the e
rror code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
** Set Field[result, External("TrFile-GetDateTimeModified", "C:\Test.txt" )]
This may return the result: "2000-12-31 15:55:17".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
modificationDateTime text
gFilePath Global, text
gFilePa
yth should contain the path to the file, for example "D:\Logs\L2000_01.TXT" (Windows) or "Mac HD:Logs:Log 2000_01" (Mac). In ScriptMaker add the following script step:
Set Field[modificationDateTime, External("TrFile-GetDateTimeModified", gFilePath )]
This will store the modification date and time of the file specified by gFilePath in the field modificationDateTime.
4/3/2000
4:13:56 PM
TrFile-GetFileCreatorf
FileSpecj
Filesu
Troi File Plug-in
D0001
JCSet Field [ result, External("TrFile-GetFileCreator", "FileSpec" )]
K=Returns the Creator for the file specified by the FileSpec.
MNFileSpec: the Filespec or path to the file for which you want the information.
Set Field[result, External("TrFile-GetFileType", "KES:readme" )]
This will (probably) return "ttxt" which is the Creator for the SimpleText application.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
creator text
gFilePath Global, text
gFilePath should contain the path to the file, for example "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[creator, External("TrFile-GetFileType", gFilePath )]
This willBM store the Creator of the file specified by gFilePath in the field "creator".
Creator: The Creator of a file is a 4 character code used to designate the application that created a file. For example: FileMaker Pro 4 creates database files with a Creator "FMP3".
This function is not available in Windows.
See also the function "TrFile-GetFileType" to get the FileType.
Returns the Creator for the file specified by the FileSpec.
** FileSpec: the Filespec or path to the file for which you want the information.
** Creator: The Creator of a file is a 4 character code used to designate the application that created a file. For example: FileMaker Pro 4 creates database files with a Creator "FMP3".
This function is not available in Windows.
See also the function "TrFile-GetFileType" to get the FileType.
** Set Field[result, External("TrFile-GetFileType"
, "KES:readme" )]
This will (probably) return "ttxt" which is the Creator for the SimpleText application.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
creator text
gFilePath Global, text
gFilePath should contain the path to the file, for example "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[creator, External("TrFile-GetFileType", gFilePath )]
This will store the Creator of the file specified by gFiC"lePath in the field "creator".
4/3/2000
4:13:56 PM
TrFile-GetFileSizef
FileSpecj
Filesu
Troi File Plug-in
D0001
J@Set Field [ result, External("TrFile-GetFileSize", "FileSpec" )]
Returns the file size for the file specified by the FileSpec. The size indicates the size the file is using on the disk, not the actual size of the data and resources.
M,FileSpec: the Filespec or path to the file.
Assume there is a file "Read me" with the text "Hello!" in it. Then:
Set Field[MyTextField, External("TrFile-GetFileSize", "Disk:Read me")]
returns 1024 (= 1 Kb) which is the size used on disk.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text
gSize Global, number
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In ScriptMaker add the folloB
wing scriptstep:
Set Field[gSize, External("TrFile-GetFileSize", gFileSpec)]
This will fill gSize with the total size of the file.
O2The size (in number of bytes) of the file on disk.
Returns the file size for the file specified by the FileSpec. The size indicates the size the file is using on the disk, not the actual size of the data and resources.
** FileSpec: the Filespec or path to the file.
** The size (in number of bytes) of the file on disk.
** Assume there is a file "Read me" with the text "Hello!" in it. Then:
Set Field[MyTextField, External("TrFile-GetFileSize", "Disk:Read me")]
returns 1024 (= 1 Kb) which is the size used on disk.
EXAMPLE 2
assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text
gSize Global, number
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gSize, External("TrFile-GetFileSize", gFileSpec)]
This will fill gSize with the total size of the file.
4/3/2000
4:13:56 PM
TrFile-GetFileTypef
FileSpecj
Filesu
Troi File Plug-in
D0001
J@Set Field [ result, External("TrFile-GetFileType", "FileSpec" )]
K<Returns the FileType for the file specified by the FileSpec.
MNFileSpec: the Filespec or path to the file for which you want the information.
Set Field[result, External("TrFile-GetFileType", "KES:test.fp5" )]
This will (probably) return "FMP5" which is the FileType for FileMaker Pro 5.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
fileType text
gFilePath Global, text
gFilePath should contain the path to the file, for example "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[fileType, External("TrFile-GetFileType", gFilePath )]
This will store tBGhe FileType of the file specified by gFilePath in the field "fileType".
The FileType is a 4 character code used to designate the type of file. For example: FileMaker 4 files have a FileType of "FMP3" and Applications have FileType of "APPL".
This function is not available in Windows. Windows uses the 3 letter extension, like .fp3 instead.
Returns the FileType for the file specified by the FileSpec.
** FileSpec: the Filespec or path to the file for which you want the information.
** The FileType is a 4 character code used to designate the type of file. For example: FileMaker 4 files have a FileType of "FMP3" and Applications have FileType of "APPL".
This function is not available in Windows. Windows uses the 3 letter extension, like .fp3 instead.
** Set Field[result, External("TrFile-GetFileType", "KES:test.fp5" )]
s will (probably) return "FMP5" which is the FileType for FileMaker Pro 5.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
fileType text
gFilePath Global, text
gFilePath should contain the path to the file, for example "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[fileType, External("TrFile-GetFileType", gFilePath )]
This will store the FileType of the file specified by gFilePath in the field "fileType".C
4/3/2000
4:13:56 PM
TrFile-GetResForkSizef
FileSpecj
Filesu
Troi File Plug-in
D0001
JCSet Field [ result, External("TrFile-GetResForkSize", "FileSpec" )]
Returns the size of the resource fork for the file specified by the FileSpec. The size indicates the actual number of bytes used by the resource fork.
MNFileSpec: the Filespec or path to the file for which you want the information.
Assume there is a file "Read me" with the text "Hello!" in it. Then:
Set Field[MyTextField, External("TrFile-GetResForkSize", "Disk:Read me")]
might return 453 which is the size of the resource fork.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text
gSize Global, number
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In ScriptMaker add thB
e following scriptstep:
Set Field[gSize, External("TrFile-GetResForkSize", gFileSpec)]
This will fill gSize with the resource fork size of the file.
The size (in bytes) of the resource fork of the file specified. On Mac a file can have a data fork and also a resource fork. In this fork resources, like for example pictures are stored.
R*This function is not available in Windows.
Returns the size of the resource fork for the file specified by the FileSpec. The size indicates the actual number of bytes used by the resource fork.
** FileSpec: the Filespec or path to the file for which you want the information.
** The size (in bytes) of the resource fork of the file specified. On Mac a file can have a data fork and also a resource fork. In this fork resources, like for example pictures are stored.
** This function is not available in Windows.
** Assume there is a f
ile "Read me" with the text "Hello!" in it. Then:
Set Field[MyTextField, External("TrFile-GetResForkSize", "Disk:Read me")]
might return 453 which is the size of the resource fork.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text
gSize Global, number
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In ScriptMaker add the following scripts
Set Field[gSize, External("TrFile-GetResForkSize", gFileSpec)]
This will fill gSize with the resource fork size of the file.
4/3/2000
4:13:56 PM
TrFile-GetTimeCreatedf
FileSpecj
Filesu
Troi File Plug-in
D0001
JCSet Field [ result, External("TrFile-GetTimeCreated", "FileSpec" )]
KBReturns the creation time for the file specified by the FileSpec.
MNFileSpec: the Filespec or path to the file for which you want the information.
Set Field[creationTime, External("TrFile-GetTimeCreated", "C:\Test.txt" )]
This might return the number 7264 which is equivalent to the time: 02:01:04.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
creationTime time
gFilePath Global, text
gFilePath should contain the path to the file for example "D:\Logs\L01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[creationTime, External("TrFile-
The returned result is the creation time of the file. The time is in the same format as a time field (number of seconds since 00:00:00).
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
Returns the creation time for the file specified by the FileSpec.
** FileSpec: the Filespec or path to the file for which you want the information.
** The returned result is the creation time of the file. The time is in the same format as a time field (number of seconds since 00:00:00).
An error code might also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1
NB~GetTimeCreated", gFilePath )]
This will store the creation time of the file specified by gFilePath in the field creationTime.
genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
** Set Field[creationTime, External("TrFile-GetTimeCreated", "C:\Test.txt" )]
This might return the number 7264 which is equivalent to the time: 02:01:04.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
creationTime time
gFilePath Global, text
gFilePath should contain the path to the file for example "D:\Logs\L01.TXT" (Windows) or "Mac HD:C
Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[creationTime, External("TrFile-GetTimeCreated", gFilePath )]
This will store the creation time of the file specified by gFilePath in the field creationTime.
4/3/2000
4:13:57 PM
TrFile-GetTimeModifiedf
FileSpecj
Filesu
Troi File Plug-in
D0001
JDSet Field [ result, External("TrFile-GetTimeModified", "FileSpec" )]
Returns the modification time for the file specified by the FileSpec. The modification time is also displayed in the Finder or Explorer.
MNFileSpec: the Filespec or path to the file for which you want the information.
Set Field[modificationTime, External("TrFile-GetTimeModified", "C:\Test.txt" )]
This might return the number 7265 which is equivalent to the time: 02:01:05.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
modificationTime time
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[modificationTime, ExteB
rnal("TrFile-GetTimeModified", gFilePath )]
This will store the modification time of the file specified by gFilePath in the field modificationTime.
The returned result is the modification time of the file. The time is in the same format as a time field (number of seconds since 00:00:00).
An error code may also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
Returns the modification time for the file specified by the FileSpec. The modification time is also displayed in the Finder or Explorer.
** FileSpec: the Filespec or path to the file for which you want the information.
** The returned result is the modification time of the file. The time is in the same format as a time field (number of seconds since 00:00:00).
An error code may also be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
** Set Field[modificationTime, External("TrFile-GetTimeModified", "C:\Test.txt" )]
This might return the number 7265 which is equivalent to the time: 02:01:05.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
modificationTime time
gFilePath Global, text
gFilePath should
P contain the path to the file, for example "D:\Logs\L01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[modificationTime, External("TrFile-GetTimeModified", gFilePath )]
This will store the modification time of the file specified by gFilePath in the field modificationTime.
4/3/2000
4:13:57 PM
TrFile-Launchf
FileSpecj
Filesu
Troi File Plug-in
D0001
J;Set Field [ result, External("TrFile-Launch", "FileSpec" )]
Opens a file with the application that has registered it. This is the same application that would open it if you would manually double-click it.
M;fileSpec: the Filespec or path to the file to be launched.
Set Field[result, External("TrFile-Launch", "C:\readme.doc" )]
This will open the file in the application Microsoft Word.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[gErrorCode, External("TrFile-Launch", gFilePath )]
BFThis will launch the file specified by gFilePath with its application.
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was opened with its application
$$-35 nsVolErr No such volume (Wrong disk name or not mounted).
$$-43 fnfErr File not found.
$$-50 paramErr Parameter error.
$$-1 genericErr The file could not be opened.
Other errors may be returned.
On the Mac the program that opens the file is determined by the FileType of the file.
On Windows this is determined by the 3 letter extension of the file.
So a text file "ReadMe.txt" will usually be opened by SimpleText (Mac) or WordPad (Windows).
Opens a file with the application that has registered it. This is the same application that would open it if you would manually double-click it.
** fileSpec: the Filespec or path to the file to be launched.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was opened with its application
$$-35 nsVolErr No such volume (Wrong disk name or not m
ounted).
$$-43 fnfErr File not found.
$$-50 paramErr Parameter error.
$$-1 genericErr The file could not be opened.
Other errors may be returned.
** On the Mac the program that opens the file is determined by the FileType of the file.
On Windows this is determined by the 3 letter extension of the file.
So a text file "ReadMe.txt" will usually be opened by SimpleText (Mac) or WordPad (Windows).
** Set Field[result, External("TrFile-Launch", "C:\readme.doc" )]
This will open the
file in the application Microsoft Word.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
gFilePath should contain the path to the file, for example "D:\Logs\L01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). In ScriptMaker add the following script step:
Set Field[gErrorCode, External("TrFile-Launch", gFilePath )]
This will launch the file specified by gFilePath with its application.
K=Moves (or renames) a file from one disk location to another.
Mpsource FileSpec: the path to the file to move.
destination FileSpec: the path where the file must be moved to.
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gSourceFilePath Global, text
gDestFilePath Global, text
gSourceFilePath should contain the path to an existing file, for example "D:\Logs\Log01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). gDestFilePath should contain the path to the destination and should not exist for example "D:\New\L2000_01.TXT" (Windows) or "Mac HD:New:Log 2000_01" (Mac). In ScriptMaker add the following script
step:
Set Field[gErrorCode, External("TrFile-MoveFile", gSourceFilePath & "|" & gDestFilePath )]
This will move the source file to the path indicated in the gDestFilePath.
EXAMPLE 2
Renaming a file: assume your C disk already contains a file "Testtext.txt". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-MoveFile", "C:\Testtext.txt|C:\NewName.txt" )]
This script will move (rena
me) the file "Testtext.txt" to the "NewName.txt" file in the same directory. Note that on Mac OS the paths will be like: "Work Disk:NewName.txt".
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was moved
$$-43 fnfErr Source file not found, or destination directory does not exist
$$-48 dupFNErr Destination file already exists
$$-1 genericErr The file could not be moved
Other errors may be returned.
TIP: You can also use this function to rename a file
See also the functions "TrFile-Get FileSpec Dialog" and "TrFile-Save FileSpec Dialog" to get a FileSpec for a file.
This function only works for source and destination on the same disk.
Moves (or renames) a file from one disk location to another.
** source FileSpec: the path to the file to move.
destination FileSpec: the path where the file must be moved to.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The file was moved
$$-43 fnfErr Source file not found, or destination directory does not exist
$$-48 dupFNErr Destina
tion file already exists
$$-1 genericErr The file could not be moved
Other errors may be returned.
** TIP: You can also use this function to rename a file
See also the functions "TrFile-Get FileSpec Dialog" and "TrFile-Save FileSpec Dialog" to get a FileSpec for a file.
This function only works for source and destination on the same disk.
** We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gSourceFilePath Global, text
gDestFil
ePath Global, text
gSourceFilePath should contain the path to an existing file, for example "D:\Logs\Log01.TXT" (Windows) or "Mac HD:Logs:Log 1" (Mac). gDestFilePath should contain the path to the destination and should not exist for example "D:\New\L2000_01.TXT" (Windows) or "Mac HD:New:Log 2000_01" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-MoveFile", gSourceFilePath & "|" & gDestFilePath )]
This will move the source file to the p
ath indicated in the gDestFilePath.
EXAMPLE 2
Renaming a file: assume your C disk already contains a file "Testtext.txt". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-MoveFile", "C:\Testtext.txt|C:\NewName.txt" )]
This script will move (rename) the file "Testtext.txt" to the "NewName.txt" file in the same directory. Note that on Mac OS the paths will be like: "Work Disk:NewName.
Presents the user with a dialog, in which the user can specify where to save a file. The function returns with the FileSpec of the chozen file. Use this FileSpec for other File plug-in functions.
prompt: the prompt that will be displayed to instruct the user.
defaultName (optional) the default file name of the file to be saved.
initialFolder: (optional) the FileSpec or path to the folder where the dialog initially starts.
9 Set Field[myFileName, External("TrFile-Save FileSpec Dialog",
"Please choose a file to create|myFile.txt|" & gInititialDir)]
If [Left(myFileName, 2) <> "$$"]
Set Field[gErrorCode, External("TrFile-CreateFile", myFileName )]
Endif
This will ask the user for a file to create, which is then created.
FileSpec: The function returns a FileSpec for the selected file.
Use this FileSpec as the basis for other File plug-in functions.
If the user cancels an error code of "$$-1" is returned.
Presents the user with a dialog, in which the user can specify where to save a file. The function returns with the FileSpec of the chozen file. Use this FileSpec for other File plug-in functions.
** prompt: the prompt that will be displayed to instruct the user.
defaultName (optional) the default file name of the file to be saved.
initialFolder: (optional) the FileSpec or path to the folder where the dialog initially starts.
** FileSpec: The function returns a FileSpec for the selected fi
Use this FileSpec as the basis for other File plug-in functions.
If the user cancels an error code of "$$-1" is returned.
** Set Field[myFileName, External("TrFile-Save FileSpec Dialog",
"Please choose a file to create|myFile.txt|" & gInititialDir)]
If [Left(myFileName, 2) <> "$$"]
Set Field[gErrorCode, External("TrFile-CreateFile", myFileName )]
Endif
This will ask the user for a file to create, which is then created.
K8Search a volume (disk) for a file or folder (directory).
switches: these determine the items that are listed.
volume: the name of the volume on which to search
searchName the (part of the) filename or foldername you want to find
switches can be one or more of the following:
files search for files
folders search for folders
exactname the filename must exactly match the searchname
showaliases search also aliases (shortcuts)
showshortcuts search also aliases (shortcuts) (you can use the one you like)
showinvisibles search also invisiblB
e files and folders
Set Field [ result, External("TrFile-Search", "files &folders |KES: |readme")]
This will return a list of all files and folders on the hard disk "Mac HD" with the name 'readme'. Note that the order of the switches is not relevant, and also the & is just there for readability. This might be returned:
KES:Foto, film, geluid:Geluiden:Alert!!!:Readme
KES:Programma's:Beeld:GIFConverter 2.3.7
:README-registration
KES:Programma's:Beeld:
MOVIE:OBJTOOL:README, Make QTVR Object
etc...Bp
On Windows an example use is:
Set Field [ result, External("TrFile-Search", "files &folders |C:|readme")]
O:paths a list of paths of the items separated by returns.
At the moment you can only search a complete volume.
Search a volume (disk) for a file or folder (directory).
** switches: these determine the items that are listed.
volume: the name of the volume on which to search
searchName the (part of the) filename or foldername you want to find
switches can be one or more of the following:
files search for files
folders search for folders
exactname the filename must exactly match the searchname
showaliases search also aliases (shortcuts)
showshortcuts search also aliases (shortcuts) (you c
an use the one you like)
showinvisibles search also invisible files and folders
** paths a list of paths of the items separated by returns.
At the moment you can only search a complete volume.
** Set Field [ result, External("TrFile-Search", "files &folders |KES: |readme")]
This will return a list of all files and folders on the hard disk "Mac HD" with the name 'readme'. Note that the order of the switches is not relevant, and also the & is just there for readability. This migh
?t be returned:
KES:Foto, film, geluid:Geluiden:Alert!!!:Readme
KES:Programma's:Beeld:GIFConverter 2.3.7
:README-registration
KES:Programma's:Beeld:
MOVIE:OBJTOOL:README, Make QTVR Object
etc...
On Windows an example use is:
Set Field [ result, External("TrFile-Search", "files &folders |C:|readme")]
4/3/2000
4:13:57 PM
TrFile-SetContentsf
FileSpecj
Filesu
Troi File Plug-in
D0001
J<Set Field [ result, External("TrFile-SetContents", "text" )]
KUSets the contents of an existing file indicated by the
SetDefaultFileSpec
function.
M8text: the characters that you want to write in the file.
Assume your C disk already contains a file "Testtext.txt" which is empty. We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", "C:\Testtext.txt" )]
Set Field[gErrorCode, External("TrFile-SetContents", "Hello there." )]
This script will set the contents of the file "C:\Testtext.txt" to the text "Hello there.".
EXAMPLE 2
We assume that in your FileMaker file the following fiel
ds are defined:
gErrorCode Global, number
gFilePath Global, text
textField text
gFilePath should contain the path to an existing file, for example "D:\Hello.TXT" (Windows) or "Disk1:Hello" (Mac). TextField contains the text you want to write. In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gFilePath )]
Set Field[gErrorCode, External("TrFile-SetContents", textField)]
This will set the default file to your file. Th
NC$en the text is written to the file.
oThe returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The string of characters was written in the file
$$-1 genericErr The file could not be opened for writing (You may need to create the file first).
Other errors may be returned.
See also the functions:
"TrFile-Save FileSpec Dialog" to get a FileSpec for the file,
TrFile-SetDefaultFileSpec
to indicate the file to affect.
Sets the contents of an existing file indicated by the
SetDefaultFileSpec
function.
** text: the characters that you want to write in the file.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The string of characters was written in the file
$$-1 genericErr The file could not be opened for writing (You may need to create the file first).
Other e
rrors may be returned.
** See also the functions:
"TrFile-Save FileSpec Dialog" to get a FileSpec for the file,
TrFile-SetDefaultFileSpec
to indicate the file to affect.
** Assume your C disk already contains a file "Testtext.txt" which is empty. We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", "C:\Testtext.txt" )]
Set Field[gErrorCode, External("TrFile-SetContents", "He
llo there." )]
This script will set the contents of the file "C:\Testtext.txt" to the text "Hello there.".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
textField text
gFilePath should contain the path to an existing file, for example "D:\Hello.TXT" (Windows) or "Disk1:Hello" (Mac). TextField contains the text you want to write. In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-SetContents", textField)]
This will set the default file to your file. Then the text is written to the file.
4/3/2000
4:13:57 PM
TrFile-SetDefaultCreatorf
FileSpecj
Filesu
Troi File Plug-in
D0001
JESet Field [ result, External("TrFile-SetDefaultCreator", "Creator" )]
Specifies the file creator to be used when creating a new file. This creator will be used for subsequent calls to "TrFile-CreateFile".
Creator: The Creator of a file is a 4 character code used to designate the application that created a file. For example: use "ttxt" to create a SimpleText text file.
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
textField text
gFilePath should contain the path to an existing file, for example "D:\Hello.TXT" (Windows) or "Disk1:Hello" (Mac). TextField contains the text you want to write. In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gFilePath )]
Set Field[gErrorCode, External("TrFile-SetDefaultCreator",
"ttxt")]
Set Field[gErrorCode, External("TrFile-SetDefaultFileType", "TEXT")]
Set Field[gErrorCode, External("TrFile-SetContents", textField)]
This will set the default file to your file with a SimpleText FileType and Creator. Then the text is written to the file.
OZThis function does not return anything at the moment. This may change in a future version.
RcSee also the function "TrFile-CreateFile" to create a new empty file.
Mac only. Ignored on Windows.
Specifies the file creator to be used when creating a new file. This creator will be used for subsequent calls to "TrFile-CreateFile".
** Creator: The Creator of a file is a 4 character code used to designate the application that created a file. For example: use "ttxt" to create a SimpleText text file.
** This function does not return anything at the moment. This may change in a future version.
** See also the function "TrFile-CreateFile" to create a new empty file.
Mac only. Ignored on
Windows.
** We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
textField text
gFilePath should contain the path to an existing file, for example "D:\Hello.TXT" (Windows) or "Disk1:Hello" (Mac). TextField contains the text you want to write. In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gFilePath )]
Set Field[gErrorCode, External("TrFile-SetDefa
&ultCreator", "ttxt")]
Set Field[gErrorCode, External("TrFile-SetDefaultFileType", "TEXT")]
Set Field[gErrorCode, External("TrFile-SetContents", textField)]
This will set the default file to your file with a SimpleText FileType and Creator. Then the text is written to the file.
4/3/2000
4:13:57 PM
TrFile-SetDefaultFileSpecf
FileSpecj
Filesu
Troi File Plug-in
D0001
JGSet Field [ result, External("TrFile-SetDefaultFileSpec", "FileSpec" )]
KhIndicates a FileSpec (i.e. the file) to be used in succeeding functions where no FileSpec is indicated.
M,FileSpec: the Filespec or path to the file.
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
textField text
gFilePath should contain the path to an existing file, for example "D:\Hello.TXT" (Windows) or "Disk1:Hello" (Mac). TextField contains the text you want to write. In ScriptMaker add the following scriptsteps:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gFilePath )]
Set Field[gErrorCode, External("TrFile-SetDefaultCreator",
"ttxt")]
Set Field[gErrorCode, External("TrFile-SetDefaultFileType", "TEXT")]
Set Field[gErrorCode, External("TrFile-SetContents", textField)]
This will set the default file to your file with a SimpleText FileType and Creator. Then the text is written to the file.
OZThis function does not return anything at the moment. This may change in a future version.
Indicates a FileSpec (i.e. the file) to be used in succeeding functions where no FileSpec is indicated.
** FileSpec: the Filespec or path to the file.
** This function does not return anything at the moment. This may change in a future version.
** We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
textField text
gFilePath should contain the path to an existing file, for example "D:\Hello.TXT" (Windows) o
r "Disk1:Hello" (Mac). TextField contains the text you want to write. In ScriptMaker add the following scriptsteps:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gFilePath )]
Set Field[gErrorCode, External("TrFile-SetDefaultCreator", "ttxt")]
Set Field[gErrorCode, External("TrFile-SetDefaultFileType", "TEXT")]
Set Field[gErrorCode, External("TrFile-SetContents", textField)]
This will set the default file to your file with a SimpleText FileType and Creator. C*Then the text is written to the file.
4/3/2000
4:13:57 PM
TrFile-SetDefaultTypef
1i&[FileType1FileType2FileType3FileType4]j
Filesu
Troi File Plug-in
D0001
JaSet Field [ result, External("TrFile-SetDefaultType", "[FileType1FileType2FileType3FileType4]" )]
K{Sets the FileType to be displayed when browsing GetFile dialogs. Also sets the default file type when creating new files.
If no parameter is specified, the "TrFile-Get FileSpec Dialog" in the new function will display all files.
Individual file type must contain 4 characters and is case sensitive. Add more file types without separators.
Set Field[gButtonNr, External("TrFile-SetDefaultType", "TEXTttro") to display SimpleText and Teach Text read-only files.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
textField text
gFilePath should contain the path to an existing file, for example "D:\Hello.TXT" (Windows) or "Disk1:Hello" (Mac). TextField contains the text you want to write. In ScriptMaker add the following scriptsteps:
et Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gFilePath )]
Set Field[gErrorCode, External("TrFile-SetDefaultCreator", "ttxt")]
Set Field[gErrorCode, External("TrFile-SetDefaultType", "TEXT")]
Set Field[gErrorCode, External("TrFile-SetContents", textField)]
This will set the default file to your file with a SimpleText FileType and Creator. Then the text is written to the file.
OZThis function does not return anything at the moment. This may change in a future version.
RcSee also the function "TrFile-CreateFile" to create a new empty file.
Mac only. Ignored on Windows.
Sets the FileType to be displayed when browsing GetFile dialogs. Also sets the default file type when creating new files.
** If no parameter is specified, the "TrFile-Get FileSpec Dialog" in the new function will display all files.
Individual file type must contain 4 characters and is case sensitive. Add more file types without separators.
** This function does not return anything at the moment. This may change in a future version.
** See also the function "TrFile-CreateFile" to create
a new empty file.
Mac only. Ignored on Windows.
** Set Field[gButtonNr, External("TrFile-SetDefaultType", "TEXTttro") to display SimpleText and Teach Text read-only files.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath Global, text
textField text
gFilePath should contain the path to an existing file, for example "D:\Hello.TXT" (Windows) or "Disk1:Hello" (Mac). TextField contains the text you want to write.
In ScriptMaker add the following scriptsteps:
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gFilePath )]
Set Field[gErrorCode, External("TrFile-SetDefaultCreator", "ttxt")]
Set Field[gErrorCode, External("TrFile-SetDefaultType", "TEXT")]
Set Field[gErrorCode, External("TrFile-SetContents", textField)]
This will set the default file to your file with a SimpleText FileType and Creator. Then the text is written to the file.
4/3/2000
4:13:57 PM
TrFile-ThumbnailToClipf
switches | FileSpecj
Filesu
Troi File Plug-in
D0001
JOSet Field [ result, External("TrFile-ThumbnailToClip", "switches | FileSpec" )]
KfCreates a thumbnail (a small image of 80x80 pixels) from a graphics file and puts it on the clipboard.
switches: reserved for future use., leave empty or set to "-unused" .
FileSpec: the Filespec or path to the file from which to create a thumbnail.
Go To Layout[container Layout]
Set Field [ result, External("TrFile-ThumbnailToClip", "-unused | Mac HD:photo.jpeg" )]
Paste[container field]
This will create a thumbnail and put it in a container field
EXAMPLE 2
Say you want to create the thumbnails of filepaths that are stored in a set of records. We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
filePath text, contains the path to a file
thumbnailField container
lePath should contain the full path to existing files, for example "Mac HD:Aap.JPG" (Mac). In ScriptMaker add the following script steps:
Go To Layout[ container Layout]
Go to Record[first]
Loop
Set Field[gErrorCode, External("TrFile-ThumbnailToClip", "-unused|" & filePath)]
Paste[thumbnailField]
Go to Record[next, exit after last]
End Loop
This will try to create thumbnails for all files for the records of the found set.
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The thumbnail was created
$$-2020 movieToolboxUninitialized QuickTime not available
$$-2003 cantFindHandler No thumbnail could be created
$$-1 genericErr (Windows) function not available in this version
Other errors may be returned.
An error code $$-2003 is returned when you try to create a thumbnail for a file that has no graphics, for example a text file or a spreadsheet. It is no problem if you don't know if a file has a thumbnail. Just try to create a thumbnail, if you get the error $$-2003 you know it is not possible.
NOTE1: When you want to paste from the clipboard the container field needs to be on the current layout.
NOTE2: When unsuccessful the clipboard can still be emptied by the plug-in.
You need to hav
RBEe QuickTime installed in order to view the pictures in the database!
Creates a thumbnail (a small image of 80x80 pixels) from a graphics file and puts it on the clipboard.
** switches: reserved for future use., leave empty or set to "-unused" .
FileSpec: the Filespec or path to the file from which to create a thumbnail.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The thumbnail was created
$$-2020
movieToolboxUninitialized QuickTime not available
$$-2003 cantFindHandler No thumbnail could be created
$$-1 genericErr (Windows) function not available in this version
Other errors may be returned.
** An error code $$-2003 is returned when you try to create a thumbnail for a file that has no graphics, for example a text file or a spreadsheet. It is no problem if you don't know if a file has a thumbnail. Just try to create a thumbnail, if you get the error $$-2003 you kn
ow it is not possible.
NOTE1: When you want to paste from the clipboard the container field needs to be on the current layout.
NOTE2: When unsuccessful the clipboard can still be emptied by the plug-in.
You need to have QuickTime installed in order to view the pictures in the database!
** Go To Layout[container Layout]
Set Field [ result, External("TrFile-ThumbnailToClip", "-unused | Mac HD:photo.jpeg" )]
Paste[container field]
This will create a thumbnail and put it in a con
tainer field
EXAMPLE 2
Say you want to create the thumbnails of filepaths that are stored in a set of records. We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
filePath text, contains the path to a file
thumbnailField container
filePath should contain the full path to existing files, for example "Mac HD:Aap.JPG" (Mac). In ScriptMaker add the following script steps:
Go To Layout[ container Layout]
Go to Record[first]
Loop
Set Field[gErrorCode, External("TrFile-ThumbnailToClip", "-unused|" & filePath)]
Paste[thumbnailField]
Go to Record[next, exit after last]
End Loop
This will try to create thumbnails for all files for the records of the found set.
4/3/2000
4:13:57 PM
TrFile-Versionf
nonej
Filesu
Troi File Plug-in
D0001
J4Set Field [ result, External("TrFile-Version", "") ]
K{Use this function to see which version of the plug-in is loaded.
Note: This function is also used to register the plug-in.
M*No parameters, leave empty for future use.
We assume that a calculation number field cVersion is defined like this:
cVersion = External("TrFile-Version, "")
This will evaluate to "Troi File Plug-in <version number>". This currently returns "Troi File Plug-in 2.0b1".
OkThe name and version number of the loaded plug-in.
The function returns "" if this plug-in is not loaded.
Important: always use this function to determine if the plug-in is loaded. If the plug-in is not loaded use of external functions may result in data loss, as FileMaker will return an empty field to any external function that is not loaded.
Use this function to see which version of the plug-in is loaded.
Note: This function is also used to register the plug-in.
** No parameters, leave empty for future use.
** The name and version number of the loaded plug-in.
The function returns "" if this plug-in is not loaded.
** Important: always use this function to determine if the plug-in is loaded. If the plug-in is not loaded use of external functions may result in data loss, as FileMaker will return an empty field to any external
function that is not loaded.
** We assume that a calculation number field cVersion is defined like this:
cVersion = External("TrFile-Version, "")
This will evaluate to "Troi File Plug-in <version number>". This currently returns "Troi File Plug-in 2.0b1".
4/3/2000
4:13:57 PM
TrFile-SelectFolderDialogf
Troi File Plug-in
J`Set Field [ result, External("TrFile-SelectFolderDialog", "switches | prompt | path to start" )]
With this function the user can select a folder on disk. The function will show the user a standard dialog with the hierarcy of folders on the computer.
switches: reserved for future use, leave empty or set to "-unused".
prompt: the prompt that will be displayed to tell the user which folder to select.
path to start: the path to a folder on disk that will be used as the starting point for the selection dialog.
Set Field[result, External("TrFile-SelectFolderDialog",
"-unused |Please choose a folder where you want to put the files.|C:\Data\")]
This will present a folder selection dialog. The dialog initially shows the folder: "C:\Data\". The user can then select a folder and click on OK. The function returns with the path to the folder, for example: "D:\MyFiles\Databases\".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFolderPath Global, text
gInitialFolder Global, text
gInitialFolder should contain the path to a folder, for example "D:\Logs\Data\" (Windows) or "Mac HD:Logs:Data:" (Mac OS). In ScriptMaker add the following script step:
Set Field[gFolderPath, External("TrFile-SelectFolderDialog",
"-unused |Please choose a folder where you want to put the files.|" &gInitialFolder)]
After the dialog gFolderPath will contain the path to the selected folder.
FileSpec: The function returns a FileSpec for the selected folder. This folder can be used
with other functions of the plug-in.
If the user cancels an error code of "$$-1" is returned.
With this function the user can select a folder on disk. The function will show the user a standard dialog with the hierarcy of folders on the computer.
** switches: reserved for future use, leave empty or set to "-unused".
prompt: the prompt that will be displayed to tell the user which folder to select.
path to start: the path to a folder on disk that will be used as the starting point for the selection dialog.
** FileSpec: The function returns a FileSpec for the selected folder. Th
is folder can be used
with other functions of the plug-in.
If the user cancels an error code of "$$-1" is returned.
** Set Field[result, External("TrFile-SelectFolderDialog",
"-unused |Please choose a folder where you want to put the files.|C:\Data\")]
This will present a folder selection dialog. The dialog initially shows the folder: "C:\Data\". The user can then select a folder and click on OK. The function returns with the path to the folder
, for example: "D:\MyFiles\Databases\".
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFolderPath Global, text
gInitialFolder Global, text
gInitialFolder should contain the path to a folder, for example "D:\Logs\Data\" (Windows) or "Mac HD:Logs:Data:" (Mac OS). In ScriptMaker add the following script step:
Set Field[gFolderPath, External("TrFile-SelectFolderDialog",
"-unused |Please choose a folder where you want to put tDohe files.|" &gInitialFolder)]
After the dialog gFolderPath will contain the path to the selected folder.
4/3/2000
4:13:57 PM
TrFile-Substitutef
Troi File Plug-in
D0001
Set Field [ result, External("TrFile-Substitute", "switches | sourceFile | destinationFile | search string | replace string" )]
Substitutes every occurrence of a specified set of characters in a (text) file with another set of characters you specify, and writes the revised file. The Substitute function is case sensitive.
switches: these determine how the function works. At the moment you can specify how
the function handles case differences.
sourceFile: the Filespec or path to the file which is the source for the substitution.
destinationFile: the Filespec or path where the resulting file must be written to.
search string: any text expression or field containing text.
replace string: any text expression or field containing text.
switches can be one of the following:
-CaseSensitive substitute stringsBm only if the case of the source string is the same.
-IgnoreCase substitute strings even if the case differs.
This will create the file "C:\Main.TAB" where all occurences of "country" are replaced with the string "world". The case is ignored, so that also a string "Country" will be substituted.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number gSearchStr Global, text
gSourceFilePa
th Global, text gReplaceStr Global, text
gDestFilePath Global, text
gSourceFilePath should contain the path to an existing file, for example "D:\TempLogs\Log01.TXT" (Windows) or "Mac HD:TempLogs:Log 1" (Mac).
gDestFilePath should contain the path to the destination and should not exist, for example "D:\Output\L2000_01.TXT" (Windows) or "Mac HD:Output:Log 2000_01" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-Substitute", "-Case
This will create a new file gDestFilePath where all occurences of gSearchStr are replaced with the contents of gReplaceStr.
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The destination file with the substitutions was created.
$$-43 fnfErr Source file not found, or destination directory does not exist
$$-48 dupFNErr Destination file already exists
$$-1 genericErr The substitution could not be made.
Other errors may be returned.
Substitutes every occurrence of a specified set of characters in a (text) file with another set of characters you specify, and writes the revised file. The Substitute function is case sensitive.
** switches: these determine how the function works. At the moment you can specify how
the function handles case differences.
sourceFile: the Filespec or path to the file which is the source for the substitution.
destinationFile: the Filespec or path where the resulting file must be written to
search string: any text expression or field containing text.
replace string: any text expression or field containing text.
switches can be one of the following:
-CaseSensitive substitute strings only if the case of the source string is the same.
-IgnoreCase substitute strings even if the case differs.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error
The destination file with the substitutions was created.
$$-43 fnfErr Source file not found, or destination directory does not exist
$$-48 dupFNErr Destination file already exists
$$-1 genericErr The substitution could not be made.
Other errors may be returned.
** Set Field[result, External("TrFile-Substitute",
This will create the file "C:\Main.TAB" where all occurences
of "country" are replaced with the string "world". The case is ignored, so that also a string "Country" will be substituted.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number gSearchStr Global, text
gSourceFilePath Global, text gReplaceStr Global, text
gDestFilePath Global, text
gSourceFilePath should contain the path to an existing file, for example "D:\TempLogs\Log01.TXT" (Windows) or "Mac HD:TempLogs:Log
1" (Mac).
gDestFilePath should contain the path to the destination and should not exist, for example "D:\Output\L2000_01.TXT" (Windows) or "Mac HD:Output:Log 2000_01" (Mac). In ScriptMaker add the following scriptstep:
Set Field[gErrorCode, External("TrFile-Substitute", "-CaseSensitive|" & gSourceFilePath &
This will create a new file gDestFilePath where all occurences of gSearchStr are replaced with the contents oF
f gReplaceStr.
4/3/2000
4:13:57 PM
TrFile-UnmountDiskf
Troi File Plug-in
J@Set Field [ result, External("TrFile-UnmountDisk", "diskname" )]
K2Unmounts and ejects a removable disk. Mac OS only.
M.diskname the name of the disk to be ejected.
Set Field[result, External("TrFile-UnmountDisk", "Mac HD:" )]
This will eject the hard disk "Mac HD", provided it is not the startup disk.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gDiskName Global, text
gFilePath should contain the path to the disk, for example "Archive CD:" (Mac). In ScriptMaker add the following script step:
Set Field[gErrorCode, External("TrFile-UnmountDisk", gDiskName )]
This will ejectB! the disk specified by gDiskName.
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The disk was ejected.
$$-35 nsVolErr No such volume (Wrong disk name or not mounted).
$$-47 fBsyErr File is busy,
$$-5010 afpFileBusy Can't eject as the disk is being shared.
Other errors may be returned.
R$Best to use only on Ejectable Disks.
Unmounts and ejects a removable disk. Mac OS only.
** diskname the name of the disk to be ejected.
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The disk was ejected.
$$-35 nsVolErr No such volume (Wrong disk name or not mounted).
$$-47 fBsyErr File is busy,
$$-5010 afpFileBusy Can't eject as the disk is being shared.
Other errors may be retur
** Best to use only on Ejectable Disks.
** Set Field[result, External("TrFile-UnmountDisk", "Mac HD:" )]
This will eject the hard disk "Mac HD", provided it is not the startup disk.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gDiskName Global, text
gFilePath should contain the path to the disk, for example "Archive CD:" (Mac). In ScriptMaker add the following script step:
Set Field[gErrorCode, External("Tr
TCUFile-UnmountDisk", gDiskName )]
This will eject the disk specified by gDiskName.
4/3/2000
4:13:57 PM
TrFile-ListDisksf
Troi File Plug-in
J6Set Field [ result, External("TrFile-ListDisks", "" )]
K1Lists the names of all currently available disks.
none, leave blank
Set Field[result, External("TrFile-ListDisks", "" )]
This will return a list of names of all the disks that are currently mounted, for example:
SPOCK
Fotos tm 990926
Fotos tm 991115
OGdisknames a list of names of all the disks that are currently mounted.
`Lists the names of all currently available disks.
** none, leave blank
** disknames a list of names of all the disks that are currently mounted.
** Set Field[result, External("TrFile-ListDisks", "" )]
This will return a list of names of all the disks that are currently mounted, for example:
SPOCK
Fotos tm 990926
Fotos tm 991115
4/3/2000
4:13:57 PM
TrFile-MetaDataf
Troi File Plug-in
JDSet Field [ result, External("TrFile-MetaData", "switch|FileSpec" )]
Gets metadata out of a graphic file. Metadata can be inserted by for example Photoshop, and can contain a description of the image, copyright information, etc.
Mswitches: these determine the metadata that is returned.
FileSpec: the FileSpec or path to the file
switches can be one or more of the following:
-getIPTC get the IPTC metadata (Photoshop's File Info)
-getExif get the Exif metadata (A standard for Digital camera's)
-getJPEGComment get the JPEG comment metadata of a JPEG file
Note that the data is returned in a raw form. At this moment we are still working on this. email us if you want more info on this.
Gets metadata out of a graphic file. Metadata can be inserted by for example Photoshop, and can contain a description of the image, copyright information, etc.
** switches: these determine the metadata that is returned.
FileSpec: the FileSpec or path to the file
switches can be one or more of the following:
-getIPTC get the IPTC metadata (Photoshop's File Info)
-getExif get the Exif metadata (A standard for Digital camera's)
-getJPEGComment get the JPEG comment metadata of a JPEG fiB
** metadata the requested metadata, if available.
** Note that the data is returned in a raw form. At this moment we are still working on this. email us if you want more info on this.
JFSet Field [ result, External("TrFile-Control", "switches |password" )]
Controls the functions of the plug-in. You can disable and enable the functions of the plug-in. This allows you to create powerful solutions, without the risk of users misusing the functions, causing unwanted or harmful results.
switches: these determine how the function works. You can disable or enable all functions.
password: the password to be used.
switches can be one of the following:
-disableAllFunctions allow the user no acces to functions
-enableAllFunctions allow the user acces to all functions
Set Field[result, External("TrFile-Control", "-disableAllFunctions |secret password")]
This will disable the functions of the plug-in.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gPassword Global, text
gPassword should contain a password, for example "rapunsel". In ScriptMaker add the following to the startup script:
Set Field[gErrorCode, External("TrFile-Control", "-disableAllFunctions|" & gPasswor
This will disable the plug-in function. When you want to use the plug-in add the following script steps:
Set Field[gErrorCode, External("TrFile-Control", "-enableAllFunctions|" & gPassword)]
... add powerful functions here...
Set Field[gErrorCode, External("TrFile-Control", "-disableAllFunctions|" & gPassword)]
This will temporary enable the plug-in functions.
sThe returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error
$$-4217 pwdAlreadySet password already set (enable first)
$$-4218 alreadyEnabled functions are already enabled
$$-4219 pwdWrong password was wrong
Other errors may be returned.
RHWhen you call a disabled function an error code of $$-4220 is returned.
Controls the functions of the plug-in. You can disable and enable the functions of the plug-in. This allows you to create powerful solutions, without the risk of users misusing the functions, causing unwanted or harmful results.
** switches: these determine how the function works. You can disable or enable all functions.
password: the password to be used.
switches can be one of the following:
-disableAllFunctions allow the user no acces to functions
-enableAllFunctions allow the user acc
es to all functions
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error
$$-4217 pwdAlreadySet password already set (enable first)
$$-4218 alreadyEnabled functions are already enabled
$$-4219 pwdWrong password was wrong
Other errors may be returned.
** When you call a disabled function an error code of $$-4220 is returned.
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gPassword Global, text
gPassword should contain a password, for example "rapunsel". In ScriptMaker add the following to the startup script:
Set Field[gErrorCode, External("TrFile-Control", "-disableAllFunctions|" & gPassword)]
This will dis
qable the plug-in function. When you want to use the plug-in add the following script steps:
Set Field[gErrorCode, External("TrFile-Control", "-enableAllFunctions|" & gPassword)]
... add powerful functions here...
Set Field[gErrorCode, External("TrFile-Control", "-disableAllFunctions|" & gPassword)]
This will temporary enable the plug-in functions.
4/3/2000
4:13:56 PM
TrFile-ConvertToFMTextf
Troi File Plug-in
J@Set Field [ result, External("TrFile-ConvertToFMText", "text" )]
Converts text formatted in the format of the current operating system running on this computer to text formatted in the internal FileMaker format. On Windows the High ASCII characters (128-255) are not the same as stored internally in FileMaker.
text: the text in the native format of the operating system of this computer. This will be Windows format on Windows and Mac OS format on Mac OS.
Assume that on Windows we have the file "HighText.Doc", which contains the text "Bj
rn, <CR><LF>M
nchenstra
e 2". Add this scritstep:
Set Field[result, External("TrFile-ConvertToFMText", External("TrFile-GetContents", "C:\HighText.Doc"))]
This will store the contents of the "HighText.Doc" in the result field, with the high ASCII characters converted to the internal FileMaker format. In the result field this will look like this:
Bj
M
nchenstra
EXAMPLE 2
We assum
e that in your FileMaker file the following fields are defined:
contents text
gFileSpec Global, text
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In ScriptMaker add the following script step:
Set Field[contents, External("TrFile-GetContents", gFileSpec)]
## now the contents field is in the format of the operating system
Set Field[contents, External("TrFile-ConvertToFMText", contents)]
s will get the contents of the file into the contents field. In the second step the high ASCII characters will be converted to the internal FileMaker format. This will work transparant on both Mac OS and Windows.
O&The text in internal FileMaker format.
This function also converts line endings to the internal format. On Windows lines end with the two ASCII characters <CR><LF>. This is converted to the single character <CR> as used by the internal FileMaker format.
Converts text formatted in the format of the current operating system running on this computer to text formatted in the internal FileMaker format. On Windows the High ASCII characters (128-255) are not the same as stored internally in FileMaker.
** text: the text in the native format of the operating system of this computer. This will be Windows format on Windows and Mac OS format on Mac OS.
** The text in internal FileMaker format.
** This function also converts line endings to the inter
nal format. On Windows lines end with the two ASCII characters <CR><LF>. This is converted to the single character <CR> as used by the internal FileMaker format.
** Assume that on Windows we have the file "HighText.Doc", which contains the text "Bj
rn, <CR><LF>M
nchenstra
e 2". Add this scritstep:
Set Field[result, External("TrFile-ConvertToFMText", External("TrFile-GetContents", "C:\HighText.Doc"))]
This will store the contents of the "HighText.Doc" in the result field, with the hi
gh ASCII characters converted to the internal FileMaker format. In the result field this will look like this:
Bj
M
nchenstra
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
contents text
gFileSpec Global, text
gFileSpec should contain the path to an existing file, for example "D:\Readme.txt" (Windows) or "Mac HD:Readme.txt" (Mac). In ScriptMaker add the following script step:
Set Field[contents, External("TrFile-GetCon
~tents", gFileSpec)]
## now the contents field is in the format of the operating system
Set Field[contents, External("TrFile-ConvertToFMText", contents)]
This will get the contents of the file into the contents field. In the second step the high ASCII characters will be converted to the internal FileMaker format. This will work transparant on both Mac OS and Windows.
4/3/2000
4:13:56 PM
TrFile-ConvertFromFMTextf
Troi File Plug-in
JBSet Field [ result, External("TrFile-ConvertFromFMText", "text" )]
Converts text formatted in the internal FileMaker format to text formatted in the format of the current operating system running on this computer. On Windows the High ASCII characters (128-255) are not the same as stored internally in FileMaker.
M+text: the text in internal FileMaker format
Assume that on Windows we want to create the file "HighText.Doc", which contains the text "Bj
rn, <CR><LF>M
nchenstra
e 2". Add this scritstep:
Set Field[result, External("TrFile-ConvertFromFMText", "Bj
nchenstra
e 2")]
The result will look like:
nchenstra
e 2".
This may look wrong, but when you use for exampe the SetContents function it will appear correct on file.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
content
s text
gErrorCode Global, number
gOutputFile Global, text
gContentsConverted Global, text
gOutputFile should contain the path to a non-existing file, for example "D:\Out.txt" (Windows) or "Mac HD:Out.txt" (Mac). In ScriptMaker add the following script steps:
Set Field[gContentsConverted, External("TrFile-ConvertFromFMText", contents)]
## now gContentsConverted is in the format of the operating system
Set Field[gErrorCode, External("TrFile-CreateFile", gOutputFi
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gOutputFile)]
If [gErrorCode = 0 ]
Set Field[gErrorCode, External("TrFile-SetContents", gContentsConverted)]
Endif
This will get the contents of the contents field into the file . In the first step the high ASCII characters will be converted from the internal FileMaker format. This will work transparant on both Mac OS and Windows.
The text in the native format of the operating system of this computer. This will be Windows format on Windows and Mac OS format on Mac OS.
This function also converts line endings. In the internal FileMaker format (and on Mac) lines end with a single <CR> character. On Windows this function will replace all CR's to the normal line ending on Windows, the two characters <CR><LF>.
Note: For long texts the result can be longer than the maximum number of characters (64000). In this case the function will truncate the length to 64000 characters.
Converts text formatted in the internal FileMaker format to text formatted in the format of the current operating system running on this computer. On Windows the High ASCII characters (128-255) are not the same as stored internally in FileMaker.
** text: the text in internal FileMaker format
** The text in the native format of the operating system of this computer. This will be Windows format on Windows and Mac OS format on Mac OS.
** This function also converts line endings. In the intern
al FileMaker format (and on Mac) lines end with a single <CR> character. On Windows this function will replace all CR's to the normal line ending on Windows, the two characters <CR><LF>.
Note: For long texts the result can be longer than the maximum number of characters (64000). In this case the function will truncate the length to 64000 characters.
** Assume that on Windows we want to create the file "HighText.Doc", which contains the text "Bj
rn, <CR><LF>M
nchenstra
e 2". Add this sc
ritstep:
Set Field[result, External("TrFile-ConvertFromFMText", "Bj
nchenstra
e 2")]
The result will look like:
nchenstra
e 2".
This may look wrong, but when you use for exampe the SetContents function it will appear correct on file.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
contents text
gErrorCode Global, number
gOutputFile Global, text
gContentsConverted Global, text
gOutputFile should contain the
path to a non-existing file, for example "D:\Out.txt" (Windows) or "Mac HD:Out.txt" (Mac). In ScriptMaker add the following script steps:
Set Field[gContentsConverted, External("TrFile-ConvertFromFMText", contents)]
## now gContentsConverted is in the format of the operating system
Set Field[gErrorCode, External("TrFile-CreateFile", gOutputFile)
Set Field[gErrorCode, External("TrFile-SetDefaultFileSpec", gOutputFile)]
This will get the contents of the contents field into the file . In the first step the high ASCII characters will be converted from the internal FileMaker format. This will work transparant on both Mac OS and Windows.
4/3/2000
4:13:56 PM
TrFile-GetFileAttributef
Troi File Plug-in
JNSet Field [ result, External("TrFile-GetFileAttribute", "switch | FileSpec" )]
K;Returns an attribute of the file specified by the FileSpec.
switch: this determines the attribute that is returned.
FileSpec: the FileSpec or path to the file.
switch can be one of the following:
-lockAttr return number indicating whether the file is locked (Mac) or Read-only (Windows)
-hiddenAttr return number indicating whether the file is hidden (invisible)
-archiveAttr return number indicating whether the file's archive bit is set (Windows only)
Set Field[result, External("TrFile-GetFileAttribute", "-lockAttr| C:\test.doc")]
The result will be 1 if the file is Read-Only and 0 otherwise.
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
locked text
fileSpec text
"fileSpec" should contain the path to an existing file, for example "D:\Out.txt" (Windows) or "Mac HD:Out.txt" (Mac). In ScriptMaker add the following script step:
Set Field[locked, External("TrFile-GetFileAttribute",
NBb"-lockAttr|" & fileSpec)]
This will get the locked status of the file into the field "locked".
The returned result is the requested attribute of the file.
Result for switch "-lockAttr":
Returns 1 for a locked file and 0 for an unlocked file. On Windows it returns the equivalent "Read-only"-attribute: 1 if the file is a Read-only file and 0 otherwise.
Result for switch "-hiddenAttr":
Returns 1 if the file is hidden and 0 otherwise.
Result for switch "-archiveAttr":
Returns 1 if the file's archive bit is set and 0 otherwise. This bit is only available on Windows. On Mac OS this
W switch always returns 0.
Note that also an error code might be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
Returns an attribute of the file specified by the FileSpec.
** switch: this determines the attribute that is returned.
FileSpec: the FileSpec or path to the file.
switch can be one of the following:
-lockAttr return number indicating whether the file is locked (Mac) or Read-only (Windows)
-hiddenAttr return number indicating whether the file is hidden (invisible)
-archiveAttr return number indicating whether the file's archive bit is set (Windows only)
** The returned result is the re
quested attribute of the file.
Result for switch "-lockAttr":
Returns 1 for a locked file and 0 for an unlocked file. On Windows it returns the equivalent "Read-only"-attribute: 1 if the file is a Read-only file and 0 otherwise.
Result for switch "-hiddenAttr":
Returns 1 if the file is hidden and 0 otherwise.
Result for switch "-archiveAttr":
Returns 1 if the file's archive bit is set and 0 otherwise. This bit is only available on Windows. On Mac OS this switch always returns 0.
te that also an error code might be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)
Other errors may be returned.
** Set Field[result, External("TrFile-GetFileAttribute", "-lockAttr| C:\test.doc")]
The result will be 1 if the file is Read-Only and 0 otherwise.
EXAMPLE 2
We assume t
hat in your FileMaker file the following fields are defined:
locked text
fileSpec text
"fileSpec" should contain the path to an existing file, for example "D:\Out.txt" (Windows) or "Mac HD:Out.txt" (Mac). In ScriptMaker add the following script step:
Set Field[locked, External("TrFile-GetFileAttribute", "-lockAttr|" & fileSpec)]
This will get the locked status of the file into the field "locked".
4/3/2000
4:13:56 PM
TrFile-SetFileAttribute
Troi File Plug-in
JNSet Field [ result, External("TrFile-SetFileAttribute", "switches|FileSpec" )]
K8Sets an attribute of the file specified by the FileSpec.
switches: these determine the attribute that is set.
FileSpec: the FileSpec or path to the file.
switches can be one ore more of the following:
-lock make the file locked (Mac OS) or Read-only (Windows)
-unlock make the file unlocked (Mac OS) or remove the Read-only attribute (Windows)
-hide make the file hidden (invisible)
-unhide unhide the file (visible)
-setArchive set the file's archive bit (Windows only)
-resetArchive reset the file's archive bit (Windows only)
Set Field[result, External("TrFile-SetFileAttribute", "-lock|C:\test.doc")]
The file will be locked (made Read-Only) and the result will be 0 (provided the file exists).
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text
gLockIt Global, number (used as a boolean value)
gErrorCode Global, number
gFileSpec should contain the path to an existing file, for example "D:\Out.txt" (Windows) or "Mac HD:Out.txt" (Mac). InB
ScriptMaker add the following script step:
Set Field[gErrorCode, External("TrFile-SetFileAttribute",
If (gLockIt = 1, "-lock","-unlock") & "|" & gFileSpec)]
This will make the file locked if gLockIt is 1 and unlocked otherwise.
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The attribute was set.
$$-43 fnfErr File not found.
$$-50 paramErr There was an error with the parameter.
$$-1 genericErr An unspecified error occurred.
Other errors may be returned.
RnYou'll get a parameter error ($$-50) if you try to do opposite actions at the same time, like "-unlock -lock".
Sets an attribute of the file specified by the FileSpec.
** switches: these determine the attribute that is set.
FileSpec: the FileSpec or path to the file.
switches can be one ore more of the following:
-lock make the file locked (Mac OS) or Read-only (Windows)
-unlock make the file unlocked (Mac OS) or remove the Read-only attribute (Windows)
-hide make the file hidden (invisible)
-unhide unhide the file (visible)
-setArchive set the file's archive bit (Windows only)
etArchive reset the file's archive bit (Windows only)
** The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The attribute was set.
$$-43 fnfErr File not found.
$$-50 paramErr There was an error with the parameter.
$$-1 genericErr An unspecified error occurred.
Other errors may be returned.
** You'll get a parameter error ($$-50) if you try
to do opposite actions at the same time, like "-unlock -lock".
** Set Field[result, External("TrFile-SetFileAttribute", "-lock|C:\test.doc")]
The file will be locked (made Read-Only) and the result will be 0 (provided the file exists).
EXAMPLE 2
We assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text
gLockIt Global, number (used as a boolean value)
gErrorCode Global, number
gFileSpec should contain the path to an existing file
9, for example "D:\Out.txt" (Windows) or "Mac HD:Out.txt" (Mac). In ScriptMaker add the following script step:
Set Field[gErrorCode, External("TrFile-SetFileAttribute",
If (gLockIt = 1, "-lock","-unlock") & "|" & gFileSpec)]
This will make the file locked if gLockIt is 1 and unlocked otherwise.
4/3/2000
4:13:57 PM
TrFile-GetPathTof
Troi File Plug-in
JUSet Field [ result, External("TrFile-GetPathTo", "switch|desiredFilename|fileSize" )]
KIReturns the path to an object, at the moment the path to the currentFile.
switch: this determines which path is returned
desiredFilename: the name of the file to find
fileSize: the size of the file to find
switch can be only the following:
-currentFileName return the FileSpec of the file that is currently active (the front window).
FileSpec: The function returns a FileSpec for the current database file.
the function can also return an errorcode. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The attribute was set.
$$-43 fnfErr File not found.
$$-50 paramErr There was an error with the parameter.
$$-4215 invalidFMPVersion This function does not work with this version
Other errors may be returnedB3. user cancels an error code of "$$-1" is returned.
This function works on Windows from FileMaker version 5. On Mac OS it works from FileMaker 4.0 and later. If you use it on Windows under a version earlier than FileMaker 5 an error code "$$-4215" (kErrInvalidFMPVersion) is returned.
Also when a file is hosted as a guest, for example with FileMaker Server it can not return the path, in this case it will return an error code "$$-43" (fnfErr = file not found).
Returns the path to an object, at the moment the path to the currentFile.
** switch: this determines which path is returned
desiredFilename: the name of the file to find
fileSize: the size of the file to find
switch can be only the following:
-currentFileName return the FileSpec of the file that is currently active (the front window).
** FileSpec: The function returns a FileSpec for the current database file.
the function can also return an errorcode. An error always starts with 2 d
ollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 no error The attribute was set.
$$-43 fnfErr File not found.
$$-50 paramErr There was an error with the parameter.
$$-4215 invalidFMPVersion This function does not work with this version
Other errors may be returned. user cancels an error code of "$$-1" is returned.
** This function works on Windows from FileMaker version 5. On Mac OS it works from FileMaker 4.0
and later. If you use it on Windows under a version earlier than FileMaker 5 an error code "$$-4215" (kErrInvalidFMPVersion) is returned.
Also when a file is hosted as a guest, for example with FileMaker Server it can not return the path, in this case it will return an error code "$$-43" (fnfErr = file not found).
** Set Field [result, External("TrFile-GetPathTo",